import request, {encodeSearchParams} from "@/utils/request.js";

const PREFIX = '/user/product';

// 获取商品分类
export const getClassify = async () => {
  return await request.get(`${PREFIX}/classify`)
}

// 获取商品列表
export const getProducts = async (params) => {
    return await request.get(`${PREFIX}?${encodeSearchParams(params)}`)
}

// 获取热门商品
export const getHotProducts = async () => {
  return await request.get(`${PREFIX}/hot`)
}

// 获取专题列表
export const getThemeList = async () => {
  return await request.get(`/user/theme`)
}

// 获取商品评价
export const getProductReviews = async (id) => {
  await new Promise(resolve => setTimeout(resolve, 300))
  return [
    {
      id: 1,
      userId: 1,
      nickname: '张三',
      avatar: 'https://example.com/avatar1.jpg',
      content: '花很新鲜，包装很精美',
      rating: 5,
      images: ['https://example.com/review1.jpg'],
      createdAt: '2024-03-15 12:00:00'
    }
  ]
}
